package com.dq.domain.org;

import com.dq.vo.baseVo.VO;
import com.dq.domain.base.BaseEntity;

import com.dq.utils.TimeUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;

/**
 * @author liuhui
 * @date 2019/11/20 0020 10:49:41
 */
@Data
@Entity
@ApiModel("门店预约时间段")
public class OrgTimeQuantum extends BaseEntity implements VO.ToVO {

    @ApiModelProperty("门店")
    @ManyToOne
    protected Org sysDept;

    @ApiModelProperty("预约开始时间")
    protected String beginTime;

    @ApiModelProperty("预约结束时间")
    protected String endTime;

    @Transient
    protected Boolean flag;


    @Data
    @ApiModel(value = "门店预约时间段视图")
    public static class Vo implements VO {
        public Long id;
        public Long orgId;
        public String orgName;
        @ApiModelProperty("预约开始时间")
        protected String beginTime;
        @ApiModelProperty("预约结束时间")
        protected String endTime;
        protected Boolean flag;

        @ApiModelProperty(value = "创建时间")
        private String createTime;
        @ApiModelProperty(value = "修改时间")
        private String lastModifyTime;
        @ApiModelProperty(value = "创建者id")
        private Long createUserId;
        @ApiModelProperty(value = "创建者name")
        private String createUserName;
        @ApiModelProperty(value = "修改者id")
        private Long updateUserId;
        @ApiModelProperty(value = "修改者name")
        private String updateUserName;
    }

    @Override
    public VO toVO(boolean isRecursion) {
        Vo vo = new Vo();
        vo.id = this.getId();
        vo.orgId = this.getSysDept().getId();
        vo.orgName = this.getSysDept().getSimpleName();
        vo.beginTime = fmt(this.getBeginTime());
        vo.endTime = fmt(this.getEndTime());
        vo.flag = this.getFlag();

        vo.createTime = TimeUtil.longToString(this.createTime, TimeUtil.YYYY_MM_DD_HH_MM_SS);
        vo.lastModifyTime = TimeUtil.longToString(this.lastModifyTime, TimeUtil.YYYY_MM_DD_HH_MM_SS);
        vo.createUserId = this.createUser == null ? null : this.createUser.getId();
        vo.createUserName = this.createUser == null ? null : this.createUser.getUsername();
        vo.updateUserId = this.updateUser == null ? null : this.updateUser.getId();
        vo.updateUserName = this.updateUser == null ? null : this.updateUser.getUsername();
        return vo;
    }
}
